package com.dftc.dftcdemo.util;

import android.content.Context;

import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
import com.alibaba.sdk.android.oss.common.auth.OSSCustomSignerCredentialProvider;
import com.alibaba.sdk.android.oss.common.utils.OSSUtils;

public class OSSConfig {
    //    public static final String ENDPOINT = "http://oss-cn-hangzhou.aliyuncs.com";
//    public static final String ENDPOINT = "http://data4device.oss-cn-beijing.aliyuncs.com";
    public static final String ENDPOINT = "http://oss-cn-beijing.aliyuncs.com";
    public static final String AK = "LTAI4FkGPm2uU4AaABwgqHrk";//set your ak
    public static final String SK = "ii1FQ70LduG1XTiAWWwWnp3n0kQnVy";//set your sk
    public static String mac = "00000000/";
    public static final String buketName = "ai-snapshot";

    public static OSSCredentialProvider credentialProvider;
    private static OSSConfig sInstance;

    private static Context mContext;

    private OSSConfig(Context context) {
        credentialProvider = newCustomSignerCredentialProvider();
        mContext = context;
    }

    public static OSSConfig instance(Context context) {
        if (sInstance == null) {
            sInstance = new OSSConfig(context.getApplicationContext());
        }
        return sInstance;
    }

    public static OSSCredentialProvider newCustomSignerCredentialProvider() {
        return new OSSCustomSignerCredentialProvider() {
            @Override
            public String signContent(String content) {
                return OSSUtils.sign(AK, SK, content);
            }
        };
    }

}